{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .childrenBody {
        background: #fff;
    }
</style>
<table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
<script type="text/html" id="barTool">
    {{# if({$push}){ }}
    <a data-open='{:url("push/chapter",["catid"=>$catid])}?id={{ d.id }}&did={{ d.did }}' data-width="900" data-height="600" class="layui-btn layui-btn-xs layui-btn-warm" title="推送并翻译">推送</a>
    {{#  } }}
    <a class="layui-btn layui-btn-xs" data-open='{:url("edit",["catid"=>$catid])}?id={{ d.pid }}&did={{ d.did }}' data-title="编辑章节" data-full="true">编辑</a>
    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
</script>

<script type="text/html" id="username">
    {{# if(d.sysadd==1){ }}
    {{ d.username }}
    {{#  } else { }}
    <span class="text-danger">{{ d.username }}</span>
    {{#  } }}
</script>
<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate",["catid"=>$catid])}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="通过|待审核" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>



<style type="text/css">
    .layui-layer-page .layui-layer-content {
        overflow: inherit;
    }
</style>
{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function() {
        var table = layui.table,
            $ = layui.$,
            form = layui.form,
            table = layui.table,
            yznTable = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add',['catid'=>$catid])}?did={$did}",
            delete_url: "{:url('del',['catid'=>$catid])}",
            modify_url: '{:url("listorder",["catid"=>$catid])}',
        };

        yznTable.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            toolbar: ['refresh',
                [{
                    text: '添加',
                    title: '添加章节',
                    url: init.add_url,
                    method: 'open',
                    icon: 'iconfont icon-add',
                    class: 'layui-btn layui-btn-normal layui-btn-sm',
                    extend: 'data-full="true"',
                }], 'delete',
    ],
        url: '{:url("index",["catid"=>$catid])}?did={$did}',
            cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'listorder', width: 70, title: '排序', edit: 'text', align: "center" },
                { field: 'id', width: 60, title: 'ID' , align: "center"},
                { field: 'site', width: 120, title: '已发站点', align: "center"},
                { field: 'chapter', align: "left", title: '标题'},
                { field: 'image', width: 88, title: '图片', search: false, templet: yznTable.image },
                { field: 'hits', width: 80, title: '点击量', align: "center" },
                { field: 'updatetime', width: 145, title: '更新时间', search: 'range' },
                { field: 'username', width: 80, title: '发布人', templet: '#username' },
                { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.url, search: false },
                { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
                { fixed: 'right', width: 180, title: '操作', toolbar: '#barTool', align: "center" }
            ]
        ],
            page: {}
    });
    });
</script>
{/block}